﻿using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace System.Diagnostics;
/// <summary>
/// Stopwatch类的扩展
/// </summary>
public static class StopwatchExtend {
    /// <summary>
    /// 同步阻塞延时等待 参数 miliSeconds 指定的毫秒数
    /// </summary>
    /// <param name="stopwatch">高精度时间测试器</param>
    /// <param name="miliSeconds">等待毫秒数</param>
    public static void Delay(this Stopwatch stopwatch, int miliSeconds) {
        stopwatch.Restart();
        while (stopwatch.ElapsedMilliseconds < miliSeconds) {
            Thread.Sleep(1);
            continue;
        }
        stopwatch.Reset();
    }
}
